# Lesson 5: Simulating medium resolution meshes using custom nCloth attribute presets

Now that you have used the workflow in Lessons 3 and 4 to realistically solve the low resolution nCloth meshes, you can use them to quickly prepare a medium resolution version of the nCloth pants and shirt for simulation.

In this lesson, you will:

- Save the nCloth attributes for the Shirt_LowRes and Pants_LowRes objects as custom nCloth presets.
- Change the Scaling Relation attribute and observe its impact on the nCloth simulated meshes.

## Lesson Setup

1. If you have not already done so, download the nCloth Advanced Techniques Lesson Data from the following location: http://www.autodesk.com/maya-advancedtechniques. Then, set the nClothAdvancedTutorials directory as your Maya project.

   For this lesson, you need to access Maya geometry cache files in addition to the lesson scene file.

2. Open the scene file named Character_MedRes.mb.

   This file can be found in the nClothAdvancedTutorials directory that you set as your Maya project.

   The medium resolution shirt and pant meshes have already been converted to nCloth objects and named nCloth_Shirt_MedResShape and nCloth_Pants_MedResShape.

   A Point to Surface constraint has been applied to the pants to constrain them to the character's waist. The medium resolution shirt and pants have already been wrapped (using a wrap deformer) with a new, duplicated high resolution shirt and pants mesh. The low resolution shirt and pants, and the nCloth shirt and nCloth pants objects have been cached and are positioned next to the medium resolution meshes for reference.

3. Import the geometry caches which animate the character’s body and shoes for the low resolution and medium resolution characters. See Importing geometry caches.

## Save the nCloth attributes as custom presets

By the end of Lesson 3 and 4, you generated optimized simulations of your character’s shirt and pants. A number of steps were involved in obtaining the attribute values that drive the behavior of these nCloth objects, and so you may want to save these optimized attribute values.

Using Maya attribute presets, you can save the attribute values of the low resolution nCloth shirt (nCloth_ShirtShape) and nCloth pants (nCloth_PantsShape) objects as custom nCloth presets. Your new nCloth presets can then be applied to other versions of the meshes, including the medium resolution shirt and pants. This workflow allows you to quickly prepare other simulations with geometry that has similar topology to your original objects.

To save the nCloth shirt object's attributes as a custom nCloth preset

1. In the scene view, select the low resolution nCloth shirt.
2. In the Attribute Editor, click the nCloth_ShirtShape tab.
3. Click-hold the Presets button.

   The nCloth attribute Presets pop-up menu appears.

4. Select Save nCloth Preset.

   The Save Attribute Preset window appears.

5. In the Preset name field type nCloth_ShirtShape for the name of the custom attribute preset you want to create, and then click Save Attribute Preset.
6. Repeat steps 1 to 5 to save the nCloth pants as a custom nCloth attribute preset nCloth_PantsShape.

Since you no longer need to simulate the low resolution nCloth shirt and pants, you can disable them from the Nucleus solver. Doing this increases the simulation speed of your medium resolution nCloth shirt and pants.

To disable the low resolution nCloth shirt and pants

1. In the scene view, select the low resolution nCloth shirt.
2. In the Attribute Editor, click the nCloth_ShirtShape tab.
3. Turn off Enable.
4. Repeat steps 1 to 3 for the nCloth pants object.
5. Hide the low resolution character and clothing by selecting Character_LowRes in the Outliner and then selecting Display > Hide > Hide Selection.

## Applying the custom nCloth attribute preset to the medium resolution shirt and pants

In this lesson, you apply your custom nCloth attribute presets to the medium resolution versions of the nCloth shirt and pants (nCloth_Shirt_MedResShape and nCloth_Pants_MedResShape). After the attribute presets are applied, you can fine tune the simulation by adjusting the Collisions, Dynamic Properties, and Quality Setting attributes.

To apply your custom nCloth attribute preset to the medium resolution nCloth

1. In the scene view, select the nCloth medium resolution shirt.
2. In the Attribute Editor, click the nCloth_Shirt_MedResShape tab.
3. Click-hold the Presets button, select the nCloth_ShirtShape preset, and select Replace.
4. In the scene view, select the medium resolution nCloth pants.
5. In the Attribute Editor, click the nCloth_Pants_MedResShape tab select the nCloth_PantsShape preset, and select Replace.
6. In the scene view, Shift-select the medium resolution nCloth shirt and pants, and create a new cache by selecting nCache > Create New Cache > nObject.

   The nCloth shirt and pants simulations are saved in one nCache file.

7. Play back the simulation.

## Comparing the final simulations

In the final sections of this lesson, you compare your final nCloth simulations. First, you compare the behavior of your medium resolution nCloth shirt and pant objects with your final low resolution shirt and pants simulations. This comparison allows you to see differences in the way the high resolution mesh behaves when it is wrapped on low and medium resolution meshes. In the last section, you compare all three simulation versions of nCloth (the original high resolution, medium resolution, and low resolution meshes).

To compare your medium and low resolution simulations

1. Hide the Shirt_MedRes, Pants_MedRes, Shirt_LowRes, and Pants_LowRes objects by selecting them in the Outliner, and then selecting Display > Hide > Hide Selection.
2. Show all the objects in the Character_HighRes group by selecting Pants_HighRes and Shirt_HighRes as well as Character_LowRes in the Outliner, and then selecting Display > Show > Show Selection.

   The medium resolution and low resolution nCloth meshes, each wrapped by the same high resolution shirt and pants, now appear in the scene view.

3. Play back the scene.

Dolly and tumble the scene while scrubbing the Time Slider so that you can closely observe any differences in the behavior of each nCloth object.

When you play back the simulations, you notice the following:

- The low and medium resolution shirts are behaving in the same way.
- The medium resolution pants are taking more time than the low resolution pants to settle in the first frames of the simulation.
- Between frame 1040 and 1045, the medium resolution pants ride further up on the character legs than the low resolution pants.
- At frame 1047, the cuffs of the medium resolution pants are further apart than the cuffs of the low resolution pants.
- The medium resolution pants appear to have more bounce during specific areas of the simulation.

If you are not satisfied with the behavior of your medium resolution nCloth shirt and pants, use the same attribute optimizing workflow described in Lessons 3 and 4 to adjust the Collisions, Dynamic Properties, and Quality Settings attributes.

You can remove some of the bounce from the medium resolution nCloth pants by editing the Scaling Relation attribute. When Scaling Relation is set to Link, the nCloth’s dynamic attributes, such as Bend Resistance and Stretch Resistance are calculated relative to the mesh’s scale. When Scaling Relation is set to Object, the dynamic attribute calculations are automatically scaled based on the mesh’s resolution. Low resolution meshes tend to stretch more when Scaling Relation is set to Object rather than Link. High resolution meshes tend to stretch less when Scaling Relation is set to Object rather than if Scaling Relation is set Link. For more information, see nCloth Dynamic Properties in the Maya Help.

To edit Scaling Relation

1. In the Outliner, select the medium resolution nCloth pants.
2. In the Attribute Editor, click the nCloth_Pants_MedResShape tab.
3. In the Dynamic Properties section, set Scaling Relation to Object Space.
4. Cache the simulation (nCache > Create New Cache > nObject), and play it back.

### Compare all three versions of nCloth

To compare all three versions of nCloth

1. Ensure that:
   - The Shirt_MedRes, Pants_MedRes, Shirt_LowRes, and Pants_LowRes objects are hidden.
   - All objects in the Character_HighRes group are shown in the scene.
2. In the Display Layer editor, turn on Visible for the Reference_Character object in the scene view.
3. Scrub through the Time Slider to compare how the nCloth meshes behave in the animation. Dolly and tumble the scene so that you can closely observe any subtle differences in the nCloth.
   NOTE:

   If the Reference_Character is not animated in the scene view when you play back or scrub the simulation, you may need to reconnect the reference character’s caches to their respective objects. See Reconnecting objects to existing caches.

When you compare the three versions of nCloth, you have to look closely to notice the subtle differences in behavior. Considering the amount of time saved optimizing a low resolution mesh, this workflow provides a viable alternative to simulating highly detailed character clothing. By wrapping your highly detailed mesh onto a lower resolution nCloth instead of simulating it, you can still model details into mesh without worrying about how it simulates.

By saving the low resolution nCloth attributes as a custom preset, you add value to the time invested in optimizing the nCloth simulation. After applying the preset to the medium resolution nCloth, only minimal adjustment is required to obtain a simulation with good results.